 package com.cxl.other.mode;
 
 import java.io.PrintStream;
 import java.sql.CallableStatement;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 
 public class jdbc
 {
   String dbUrl;
   String theUser;
   String thePw;
   Connection c;
   Statement conn;
   ResultSet rs;
   CallableStatement cstmt;
 
   public jdbc()
   {
     this.dbUrl = "jdbc:mysql://127.0.0.1:3306/test";
     this.theUser = "root";
     this.thePw = "root";
     this.c = null;
 
     this.rs = null;
     this.cstmt = null;
     try
     {
       Class.forName("com.mysql.jdbc.Driver").newInstance();
 
       this.c = DriverManager.getConnection(this.dbUrl, this.theUser, this.thePw);
 
       this.cstmt = this.c.prepareCall("{call insert_student(?,?,?)}");
       this.cstmt.registerOutParameter(3, 4);
       this.cstmt.setString(2, "wangwu");
       this.cstmt.setInt(1, 899);
       this.cstmt.execute();
 
       System.out.println(this.cstmt.getInt(3));
 
       this.conn = this.c.createStatement();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 
   public boolean executeUpdate(String sql) {
     try {
       this.conn.executeUpdate(sql);
       return true;
     } catch (SQLException e) {
       e.printStackTrace();
     }return false;
   }
 
   public ResultSet executeQuery(String sql)
   {
     this.rs = null;
     try {
       this.rs = this.conn.executeQuery(sql);
     } catch (SQLException e) {
       e.printStackTrace();
     }
     return this.rs;
   }
 
   public void close() {
     try {
       this.conn.close();
       this.c.close();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 
   public static void main(String[] args)
   {
     jdbc conn = new jdbc();
     ResultSet rs = conn.executeQuery("select * from Student");
     try {
       while (rs.next())
         System.out.println(rs.getString("id"));
     }
     catch (Exception e)
     {
       e.printStackTrace();
     }
   }
 }

/* Location:           E:\work\eclipse3.6_\workspace\design_pattern\
 * Qualified Name:     com.cxl.other.mode.jdbc
 * JD-Core Version:    0.6.1
 */